package com.beiing.tianshuai.tianshuai.widget;

import android.content.Context;
import android.support.v4.widget.NestedScrollView;
import android.util.AttributeSet;
import android.view.MotionEvent;

import com.beiing.tianshuai.tianshuai.util.AppBarStateChangeListener;

/**
 * Created by Jinni on 2017/7/21 0021.
 */

public class MyNestedScrollView extends NestedScrollView {

    public AppBarStateChangeListener.State mState;
    private boolean isRecyclerViewTop = false;

    public MyNestedScrollView(Context context) {
        super(context);
    }

    public MyNestedScrollView(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    @Override
    public boolean onInterceptTouchEvent(MotionEvent ev) {
        return mState != AppBarStateChangeListener.State.COLLAPSED || isRecyclerViewTop;
    }

    public void setState(AppBarStateChangeListener.State state) {
        mState = state;
    }

    public void setRecyclerViewTop(boolean recyclerViewTop) {
        isRecyclerViewTop = recyclerViewTop;
    }
}
